package de.ff7rl;

import java.lang.Thread.UncaughtExceptionHandler;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ff7rl.ui.UserInterface;

public class Main {

  private static final Logger LOG = LoggerFactory.getLogger(Main.class);

  public static void main(final String[] args) throws Exception {
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(final Thread theThread, final Throwable theCause) {
            LOG.error("An internal error occured.", theCause);
            JOptionPane.showMessageDialog(null, "An internal error occured.", "Internal error",
                JOptionPane.ERROR_MESSAGE);
            System.exit(1);
          }
        });
        new UserInterface();
      }
    });
  }

}
